package cn.iocoder.yudao.framework.common.enums.trade;

import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Arrays;

/**
 * 交易订单 - 类型
 *
 * @author Sin
 */
@RequiredArgsConstructor
@Getter
public enum TradeOrderTypeEnum implements ArrayValuable<Integer> {

    FULL_PAYMENT(0, "全款买"),
    PRICE_LOCK(1, "锁价买卖"),
    OLD_EXCHANGE(2, "旧料兑换"),
    ;

    public static final Integer[] ARRAYS = Arrays.stream(values()).map(TradeOrderTypeEnum::getType).toArray(Integer[]::new);

    /**
     * 类型
     */
    private final Integer type;
    /**
     * 类型名
     */
    private final String name;

    @Override
    public Integer[] array() {
        return ARRAYS;
    }

    public static boolean isFullPayment(Integer type) {
        return ObjectUtil.equal(type, FULL_PAYMENT.getType());
    }

    public static boolean isPriceLock(Integer type) {
        return ObjectUtil.equal(type, PRICE_LOCK.getType());
    }

    public static boolean isOldExchange(Integer type) {
        return ObjectUtil.equal(type, OLD_EXCHANGE.getType());
    }

}
